﻿using System;
using System.Collections.Generic;
using Marmat.Foundation;

namespace Marmat.FrameWork
{
    /// <summary>
    /// 系统命令
    /// </summary>
    public sealed partial class SystemCommand
    {
        /// <summary>
        /// 通过依赖注入获取 IService 类型的服务。
        /// </summary>
        /// <typeparam name="IService">需要获取的服务类型</typeparam>
        /// <returns></returns>
        public static IService GetService<IService>() where IService : class
        {
            return ServiceCollectionFactory.GetService<IService>();
        }

        /// <summary>
        /// 通过依赖注入获取T类型的服务集合。
        /// </summary>
        /// <typeparam name="IService">需要获取的服务类型</typeparam>
        /// <returns></returns>
        public static IEnumerable<IService> GetServices<IService>() where IService : class
        {
            return ServiceCollectionFactory.GetServices<IService>();
        }

        /// <summary>
        /// 获取工厂提供的服务容器。
        /// </summary>
        /// <returns></returns>
        public static IServiceProvider GetServiceProvider()
        {
            return ServiceCollectionFactory.GetServiceProvider();
        }
    }
}
